From 67e6da4627dc2e82defd03cb6db7be92bbdb9e61 Mon Sep 17 00:00:00 2001 From: Gargaj Date: Tue, 10 Nov 2015 14:00:27 +0100 Subject: Avoid division by zero It won't do much because direction will still be a nullvector, but it at least avoids a CPU spike. --- src/Entities/Pawn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 5ca0c6126..ca2d413df 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -70,7 +70,7 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition(); v3Delta.y = 0.0; // we only push sideways - v3Delta *= 1.0 / v3Delta.Length(); // we push harder if we're close + v3Delta *= 1.0 / (v3Delta.Length() + 0.01); // we push harder if we're close // QUESTION: is there an additional multiplier for this? current shoving seems a bit weak a_Entity->AddSpeed(v3Delta); -- cgit v1.2.3